﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; 

namespace SRF.Components.Logging
{
    public class LoginLogger : SRF.Common.Logging.ILoginLogger
    {
        readonly Data.DBHelperBase dbhelper = Data.DBHelperFactory.GetDBHelper();
        const string InsertLogSQL = "admin.loginlog.insert";
 
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="post"></param>
        /// <returns>返回Id</returns>
        public void Write(System.Web.HttpRequestBase request, string userId)
        {
            dbhelper.GetQuery(InsertLogSQL).SetParameter(new
            {
                UserId = userId,
                Url = request.Url.ToString(),
                Ip = request.UserHostAddress,
                Browser = request.Browser.Type,
                LoginTime = DateTime.Now
            }).Execute();
        }
    }
}